﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.Data;
using System.Data .SqlClient;

namespace WebSystem
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
      
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] == "1")
            {
                Page.Theme = "1";
            }
            else if (Session["Theme"] == "3")
            {
                Page.Theme = "3";
            }

            else
            {
                Page.Theme = "2";
            }
        }
        protected void btnregister_Click(object sender, EventArgs e)
        {
             string strCn = "server=pc.hstc.cn;database=dhd2014115121;uid=2014115121;pwd=19960404";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
               
                    cn.Open();
                    string strSql = "INSERT INTO UserInfo2(UserName, Password,Memo) VALUES   (N'" + this.txtName.Text + " ',N'" + this.txtPwd.Text + "',N'学生')";
                    SqlCommand cmd = new SqlCommand(strSql, cn);
                    int iUpd = cmd.ExecuteNonQuery();
                    if (iUpd < 1)
                    {
                        this.lblInfo.Text = "新增失败，此用户名已存在！";
                    }
                    else
                    {
                        this.lblInfo.Text = "新增成功！";
                    }
                
            
                
            }
            catch(Exception ex)
            {
                this.lblInfo.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
            }

        protected void btnback_Click(object sender, EventArgs e)
        {

            txtName.Text="";
            txtPwd.Text="";
            txtPwd1.Text="";
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((DropDownList1.SelectedItem).ToString() == "注册帐号")
            {
                Response.Redirect("MUserStuRis.aspx");
            }
            if ((DropDownList1.SelectedItem).ToString() == "删除帐号")
            {
                Response.Redirect("MUserStuDel.aspx");
            }


        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((DropDownList2.SelectedItem).ToString() == "注册帐号")
            {
                Response.Redirect("MUserTeaRis.aspx");
            }
            if ((DropDownList2.SelectedItem).ToString() == "删除帐号")
            {
                Response.Redirect("MUserTeaDel.aspx");
            }
        }

        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((DropDownList3.SelectedItem).ToString() == "注册帐号")
            {
                Response.Redirect("MUserManRis.aspx");
            }
            if ((DropDownList3.SelectedItem).ToString() == "删除帐号")
            {
                Response.Redirect("MUserManDel.aspx");
            }
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            Response.Redirect("MUserMod.aspx");
        }


        }

       
        }

     
    
        
    
